
import Vue from 'vue'
import VueRouter from 'vue-router'

// 0.模块化编程
Vue.use(VueRouter)

// 1. 路由组件
// 路由懒加载
import ErrorRoutes from '@/views/errorpages/route'
import LoginRoutes from '@/views/logins/route'
import MainRoutes from '@/views/main/route'
import Search from '@/views/search/route'
import FilmRoutes from '@/views/film/route'
import GoodRoutes from '@/views/good/route'

// 2. 定义路由配置选项
const routes = [
    {
        path: '/',
        redirect: {
        name: 'guide'
        }
    },
    {
        path: '/guide',
        name: 'guide',
        component: () => import('@/views/guide/guide.vue')
    },
    {
        path: '/city',
        name: 'city',
        component: () => import('@/views/city/city.vue')
    },
    ...ErrorRoutes,
    ...LoginRoutes,
    ...MainRoutes,
    ...Search,
    ...FilmRoutes,
    ...GoodRoutes,
    {
        path: '*',
        redirect: {
        name: '404'
        }
    },
]

// 3. 创建路由对象
const router = new VueRouter({
    routes,
    mode: 'hash'
})

// 4. 暴露挂载到根实例
export default router